import {Component, Input, OnInit, ViewEncapsulation} from '@angular/core';
import {MatchService} from "app/pages/match/match.service";

@Component({
  selector: 'match-rules',
  templateUrl: './match-rules.component.html',
  styleUrls: ['./match-rules.component.scss'],
  encapsulation: ViewEncapsulation.None
})
export class MatchRulesComponent implements OnInit {
  @Input() matchId;

  public constitution;
  public stateStore = {
    haveData: true
  };

  constructor(public service: MatchService) {
  }

  /**
   * 获取赛事详情基本信息
   * @param matchId 赛事ID
   */
  getCompetitionConstitution() {
    this.service.getCompetitionConstitution(this.matchId).subscribe(res => {
      if (res.result === '0' && res.data) {
        if (res.data.constitution) {
          this.constitution = res.data.constitution;
        } else {
          this.stateStore.haveData = false;
        }
      }
    });
  }

  ngOnInit() {
  }
}
